package com.situ.day3;

import org.junit.Test;

import java.util.Random;
import java.util.Scanner;

public class ContinueBreadDemo {
    @Test
    public void test44() {
        for (int i = 1; i <= 5; i++) {
            if (i == 3) {
                continue;
            }
            System.out.println(i);
        }
    }

    @Test
    public void test45() {
        for (int i = 1; i <= 5; i++) {
            if (i == 3) {
                break;
            }
            System.out.println(i);
        }
    }

    @Test
    public void test46() {
        //i,j,k
        for (int i = 1; i <= 5; i++) {
            System.out.println("i: " + i);
            for (int j = 1; j <= 5; j++) {
                if (j == 3) {
                    break;
                }
                System.out.println("j: " + j);
            }
        }
    }

    @Test
    public void test7() {
        Scanner scanner = new Scanner(System.in);
        //params  parameter:参数
        Random random = new Random();
        //the upper bound (exclusive). Must be positive.
        //exclude：排除、不包含
        //include:
        //value between zero (inclusive) and bound (exclusive)
        // [0,100) + 1
        // 1-100
        int num = random.nextInt(100) + 1;
        System.out.println("num: " + num);
        while (true) {//无限循环，死循环 while(true)  for(;;)
            System.out.println("猜吧！");
            int guess = scanner.nextInt();
            if (guess > num) {
                System.out.println("太大了");
            } else if (guess < num) {
                System.out.println("太小了");
            } else {
                System.out.println("恭喜你，猜对了");
                break;
            }
        }
        System.out.println("ContinueBreadDemo.test7");
    }
}
